import { Injectable } from '@nestjs/common';
import { CreateUploadDto } from './dto/create-upload.dto';
import { UpdateUploadDto } from './dto/update-upload.dto';
import { InjectModel } from '@nestjs/mongoose';
import { Upload } from './schemas/upload.schema';
import { Model } from 'mongoose';

@Injectable()
export class UploadService {
  constructor(@InjectModel(Upload.name) private uploadModel: Model<Upload>) { }
  async create(createUploadDto: CreateUploadDto) {
    if (createUploadDto) {
      return await this.uploadModel.create(createUploadDto)
    }else{
      return false
    }
  }

  async findAll() {
    const res = await this.uploadModel.find()
    return {
      code:200,
      msg:"查询成功！",
      data:res
    }
  }

  findOne(id: number) {
    return `This action returns a #${id} upload`;
  }

  update(id: number, updateUploadDto: UpdateUploadDto) {
    return `This action updates a #${id} upload`;
  }

  remove(id: number) {
    return `This action removes a #${id} upload`;
  }
}
